package volkov.ja.pages;

import org.openqa.selenium.support.FindBy;

import ru.yandex.qatools.htmlelements.annotations.Block;
import ru.yandex.qatools.htmlelements.annotations.Name;
import ru.yandex.qatools.htmlelements.element.HtmlElement;
import ru.yandex.qatools.htmlelements.element.Link;

@Name("Main Navigation")
// not working here, why??
@Block(@FindBy(css = "header nav"))
public class NavigationBlock extends HtmlElement {

	private PageManager pages;

	// @Name("Search request input")
	// @FindBy(id = "searchInput")
	// private TextInput requestInput;
	//
	// @Name("Search button")
	// @FindBy(className = "b-form-button__input")
	// private Button searchButton;

	@Name("Home link")
	@FindBy(css = "a[href $= '/']")
	private Link home;

	@Name("My Profile link")
	@FindBy(css = "a[href $= '?go=profile']")
	private Link profile;

	@Name("User Management link")
	@FindBy(css = "a[href $= '?go=users']")
	private Link userManagement;

	@Name("Log out link")
	@FindBy(css = "a[onclick $= '?logout']")
	private Link logout;

//	public NavigationBlock(PageManager pages) {
//		this.pages = pages;
//	}

	public void goHome() {
		home.click();
	}

	public void goProfile() {
		profile.click();
	}

	public void goUserManagement() {
		userManagement.click();
	}

	public void logout() {
		logout.click();
		// pages.getWait().until(alertIsPresent()).accept();
	}

	// public void search(String request) {
	// requestInput.sendKeys(request);
	// searchButton.click();
	// }

}
